home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_10.lha / 5_10 / 5_10c4.h < prev    next >
Text File  |  1993-08-08  |  807b  |  41 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Allocate the space and set the type for a given name
  6. ardata* tableentry::settype(char *nm, vartypes v)
  7.  
  8.    // allocate the data space
  9.    name *n = tbl->insert(nm);
  10.    vardata *nv = new vardata;
  11.    n->pvalue = nv;
  12.    nv->address = address_offset;
  13.  
  14.    // add in the appropriate size
  15.    switch (v)
  16. {
  17. case tinteger:
  18.     nv->type = tinteger;
  19.     address_offset += sizeinteger;
  20.     break;
  21.  
  22. case tsingle:
  23.     nv->type = tsingle;
  24.     address_offset += sizesingle;
  25.     break;
  26.  
  27. default:
  28. case tdouble:
  29.     nv->type = tdouble;
  30.     address_offset += sizedouble;
  31.     break;
  32.  
  33. case tstring:
  34.     nv->type = tstring;
  35.     address_offset += sizestring;
  36.     break;
  37. }
  38.  
  39.    return nv;
  40.  
  41.